package poc.spring.model;

import java.util.GregorianCalendar;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name = "CACHE", uniqueConstraints = {@UniqueConstraint(columnNames={"identityQualifier", "identityValue"})})
@NamedQueries({ 
	@NamedQuery(
			name  = "Cache.findAll",
			query = "SELECT b "
					+ "FROM BcsoiCacheQueryParams b "
					+ "WHERE b.adapterName = :adapterName"),
	@NamedQuery(
			name  = "Cache.getSingleResult",
			query = "SELECT b "
				  + "FROM BcsoiCacheQueryParams b "
				  + "WHERE b.identityQualifier = :identityQualifier AND b.identityValue = :identityValue"),
	@NamedQuery(
			name  = "Cache.getCountForAdapter",
			query = "SELECT COUNT(b) "
				  + "FROM BcsoiCacheQueryParams b "
				  + "WHERE b.adapterName = :adapterName"),
	@NamedQuery(
			name  = "Cache.deleteAllByAdapter",
			query = "DELETE FROM BcsoiCacheQueryParams WHERE adapterName = :adapterName")
})


public class BcsoiCacheQueryParams {
	@Id
	@GeneratedValue
	private int					id;
	private String				identityQualifier;
	private String				identityValue;
	private String				adapterName;
	private GregorianCalendar	createdtg;
	private GregorianCalendar	updatedtg;
	private GregorianCalendar	expirationDTG;
	// private CartesianRectangle2D boundingBox;
	private double				west;
	private double				north;
	private double				east;
	private double				south;
	private String				origXml;
	private String				json;
	private String				kml;
	private String				ddmsResourceXml;
	private String				resourceXml;
	private String				category;
	

	public BcsoiCacheQueryParams() { }


	public BcsoiCacheQueryParams(String identityQualifier, String identityValue, String adapterName, GregorianCalendar createdtg,
			GregorianCalendar updatedtg, GregorianCalendar expirationDTG, String category) {
		super();
		this.identityQualifier = identityQualifier;
		this.identityValue = identityValue;
		this.adapterName = adapterName;
		this.createdtg = createdtg;
		this.updatedtg = updatedtg;
		this.expirationDTG = expirationDTG;
		this.category = category;
	}
	

	public BcsoiCacheQueryParams(String identityQualifier, String identityValue, String adapterName, GregorianCalendar createdtg,
			GregorianCalendar updatedtg, GregorianCalendar expirationDTG, double west, double north, double east, double south,
			String origXml, String json, String kml, String ddmsResourceXml, String resourceXml, String category) {
		super();
		this.identityQualifier = identityQualifier;
		this.identityValue = identityValue;
		this.adapterName = adapterName;
		this.createdtg = createdtg;
		this.updatedtg = updatedtg;
		this.expirationDTG = expirationDTG;
		this.west = west;
		this.north = north;
		this.east = east;
		this.south = south;
		this.origXml = origXml;
		this.json = json;
		this.kml = kml;
		this.ddmsResourceXml = ddmsResourceXml;
		this.resourceXml = resourceXml;
		this.category = category;
	}
	

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getIdentityQualifier() {
		return identityQualifier;
	}

	public void setIdentityQualifier(String identityQualifier) {
		this.identityQualifier = identityQualifier;
	}

	public String getIdentityValue() {
		return identityValue;
	}

	public void setIdentityValue(String identityValue) {
		this.identityValue = identityValue;
	}

	public String getAdapterName() {
		return adapterName;
	}

	public void setAdapterName(String adapterName) {
		this.adapterName = adapterName;
	}

	public GregorianCalendar getCreatedtg() {
		return createdtg;
	}

	public void setCreatedtg(GregorianCalendar createdtg) {
		this.createdtg = createdtg;
	}

	public GregorianCalendar getUpdatedtg() {
		return updatedtg;
	}

	public void setUpdatedtg(GregorianCalendar updatedtg) {
		this.updatedtg = updatedtg;
	}

	public GregorianCalendar getExpirationDTG() {
		return expirationDTG;
	}

	public void setExpirationDTG(GregorianCalendar expirationDTG) {
		this.expirationDTG = expirationDTG;
	}

	public double getWest() {
		return west;
	}

	public void setWest(double west) {
		this.west = west;
	}

	public double getNorth() {
		return north;
	}

	public void setNorth(double north) {
		this.north = north;
	}

	public double getEast() {
		return east;
	}

	public void setEast(double east) {
		this.east = east;
	}

	public double getSouth() {
		return south;
	}

	public void setSouth(double south) {
		this.south = south;
	}

	public String getOrigXml() {
		return origXml;
	}

	public void setOrigXml(String origXml) {
		this.origXml = origXml;
	}

	public String getJson() {
		return json;
	}

	public void setJson(String json) {
		this.json = json;
	}

	public String getKml() {
		return kml;
	}

	public void setKml(String kml) {
		this.kml = kml;
	}

	public String getDdmsResource() {
		return ddmsResourceXml;
	}

	public void setDdmsResource(String ddmsResource) {
		this.ddmsResourceXml = ddmsResource;
	}

	public String getDdmsResourceXml() {
		return ddmsResourceXml;
	}

	public void setDdmsResourceXml(String ddmsResourceXml) {
		this.ddmsResourceXml = ddmsResourceXml;
	}

	public String getResourceXml() {
		return resourceXml;
	}

	public void setResourceXml(String resourceXml) {
		this.resourceXml = resourceXml;
	}

	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}

	@Override
	public String toString() {
		return "BcsoiCacheQueryParams [identityQualifier=" + identityQualifier + ", identityValue=" + identityValue + ", adapterName="
				+ adapterName + ", createdtg=" + createdtg + ", updatedtg=" + updatedtg + ", expirationDTG=" + expirationDTG + ", west="
				+ west + ", north=" + north + ", east=" + east + ", south=" + south + ", origXml=" + origXml + ", json=" + json + ", kml="
				+ kml + ", ddmsResourceXml=" + ddmsResourceXml + ", resourceXml=" + resourceXml + ", category=" + category + "]";
	}
}
